﻿using Abp.Domain.Repositories;
using Abp.Domain.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace shenghua.Basics.Feedbacks
{
    public class FeedbackManager : DomainService
    {
        private readonly IRepository<Feedback> _feedbackRepository;

        public FeedbackManager(
            IRepository<Feedback> feedbackRepository
            )
        {
            _feedbackRepository = feedbackRepository;
        }

        public async Task<Feedback> Get(int feedbackId)
        {
            return await _feedbackRepository.FirstOrDefaultAsync(feedbackId);
        }

        public async Task<Feedback> Create(Feedback feedback)
        {
            await _feedbackRepository.InsertAndGetIdAsync(feedback);
            return feedback;
        }

        public async Task<Feedback> Update(Feedback feedback)
        {
            return feedback;
        }

        public async Task Delete(int feedbackId)
        {
            await _feedbackRepository.DeleteAsync(feedbackId);
        }

        public async Task Audit(int feedbackId, FeedbackStatus status)
        {
            var item = await Get(feedbackId);
            item.Status = status;
        }
    }
}
